package br.com.soap.request.view;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.URL;
import java.net.URLConnection;

public class RequisicaoSOAP {

	public static void main(String[] args) throws IOException  {
		
		try{
		
		String line = "";
		URL url = new URL("http://wsh.generali.com.br/MCSServices/CalcularSeguro.asmx");
		URLConnection conn = url.openConnection();
		conn.setDoOutput(true);  
		conn.setRequestProperty("Type","Request-Response");
		conn.setRequestProperty("Content-Type", "text/xml;charset=UTF-8");
		conn.setRequestProperty("Accept-Encoding","gzip,deflate");
		conn.setRequestProperty("SOAPAction","http://ws.generali.com.br/MCSServices/CalcSeg");
		conn.setRequestProperty("User-Agent","Jakarta Commons-HttpClient/3.1");
		OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());  
        
		String xml = 
		   		"<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:mcs='http://ws.generali.com.br/MCSServices/'> <soapenv:Header/><soapenv:Body>" +
		   		" <mcs:CalcSeg> " +
        " <mcs:Entrada>" +
         "   <mcs:CdProduto>35501</mcs:CdProduto>" +
         " <mcs:DtInicVig>01/11/2013</mcs:DtInicVig>" +
         "  <mcs:DtFimVig>01/11/2014</mcs:DtFimVig>" +
         "  <mcs:DtCotProp>01/11/2013</mcs:DtCotProp>" +
         "  <mcs:CepPernoite>20270212</mcs:CepPernoite>" +
         "  <mcs:CdCober>1</mcs:CdCober>" +
         "  <mcs:CdFranq>1</mcs:CdFranq>" +
         "  <mcs:CdCiaRenov>0</mcs:CdCiaRenov>" +
         "  <mcs:ClasseBonusRenov>0</mcs:ClasseBonusRenov>" +
         "  <mcs:QtdSinis>0</mcs:QtdSinis>" +
         "  <mcs:OrigSeguro>1</mcs:OrigSeguro>" +
         "  <mcs:TpPesProp>F</mcs:TpPesProp>" +
         "  <mcs:DtNascProp>13/11/1982</mcs:DtNascProp>" +
         "  <mcs:SexoProp>F</mcs:SexoProp>" +
         "  <mcs:InFilhosAdolProp>N</mcs:InFilhosAdolProp>" +
         "  <mcs:EstCivilProp>S</mcs:EstCivilProp>" +
         "  <mcs:DtHabilitProp>10/06/2003</mcs:DtHabilitProp>" +
         "  <mcs:CPFProp>03003006460</mcs:CPFProp>" +
         "  <mcs:IndGaragemProp>N</mcs:IndGaragemProp>" +
         "  <mcs:TpPessCond>F</mcs:TpPessCond>" +
         "  <mcs:DtNascCond>13/11/1982</mcs:DtNascCond>" +
         "  <mcs:SexoCond>F</mcs:SexoCond>" +
         "  <mcs:InFilAdoCond>N</mcs:InFilAdoCond>" +
         "  <mcs:EstCivilCond>S</mcs:EstCivilCond>" +
         "  <mcs:DtHabilitCond>10/06/2003</mcs:DtHabilitCond>" +
         "  <mcs:CPFCond>03003006460</mcs:CPFCond>" +
         "  <mcs:IndGaragemCond>S</mcs:IndGaragemCond>" +
         "  <mcs:CdVeic>1063902</mcs:CdVeic>" +
         "  <mcs:CdCombust>1</mcs:CdCombust>" +
         "  <mcs:AnoModVeic>2010</mcs:AnoModVeic>" +
         "  <mcs:AnoFabrVeic>2010</mcs:AnoFabrVeic>" +
         "  <mcs:FatAjustVMR>100</mcs:FatAjustVMR>" +
         "  <mcs:CdAntifurto>0</mcs:CdAntifurto>" +
         "  <mcs:cdUsoVeic>1</mcs:cdUsoVeic>" +
         "  <mcs:cdCarroceria>0</mcs:cdCarroceria>" +
         "  <mcs:QtdPassag>4</mcs:QtdPassag>" +
         "  <mcs:InZeroKm>N</mcs:InZeroKm>" +
         "  <mcs:TpKitGas>0</mcs:TpKitGas>" +
         "  <mcs:QtdPortVeic>2</mcs:QtdPortVeic>" +
         "  <mcs:InVlDeterminado>N</mcs:InVlDeterminado>" +
         "  <mcs:VlVeiculoVD>0</mcs:VlVeiculoVD>" +
         "  <mcs:PercDescComercial>0</mcs:PercDescComercial>" +
         "  <mcs:PercComisCober>0</mcs:PercComisCober>" +
         "  <mcs:PercComisServ>0</mcs:PercComisServ>" +
         "  <mcs:ISAcessorios>0</mcs:ISAcessorios>" +
         "  <mcs:ISBlindagem>0</mcs:ISBlindagem>" +
         "  <mcs:ISKitGas>0</mcs:ISKitGas>" +
         "  <mcs:ISEquipamento>0</mcs:ISEquipamento>" +
         "  <mcs:ISMorte>1000</mcs:ISMorte>" +
         "  <mcs:ISInvalidez>1000</mcs:ISInvalidez>" +
         "  <mcs:ISRCFDM>1000</mcs:ISRCFDM>" +
         "  <mcs:ISRCFDC>1000</mcs:ISRCFDC>" +
         "  <mcs:ISRCFDMO>1000</mcs:ISRCFDMO>" +
         "  <mcs:ISDespExtraord>1000</mcs:ISDespExtraord>" +
         "  <mcs:ISEmergencia>0</mcs:ISEmergencia>" +
         "  <mcs:ISVidros>0</mcs:ISVidros>" +
         "  <mcs:ISCarroReserva>0</mcs:ISCarroReserva>" +
         "  <mcs:TamFrota>0</mcs:TamFrota>" +
         "  <mcs:CdSemiReb>0</mcs:CdSemiReb>" +
         "  <mcs:CdVidros>265</mcs:CdVidros>" +
         "  <mcs:CdEmerg>123</mcs:CdEmerg>" +
         "  <mcs:CdCarroRes>126</mcs:CdCarroRes>" +
         "  <mcs:CdEquip>0</mcs:CdEquip>" +
         "  <mcs:CdCorrSUSEP>ABCDE12345</mcs:CdCorrSUSEP>" +
         "  <mcs:CdCorrGBS>12345ABCDE</mcs:CdCorrGBS>" +
         "  <mcs:InAjustPremio>S</mcs:InAjustPremio>" +
         "  <mcs:InCustoApol>S</mcs:InCustoApol>" +
         "  <mcs:InCCB>N</mcs:InCCB>" +
         "  <mcs:VlCCB>0</mcs:VlCCB>" +
         "  <mcs:InEndosso>N</mcs:InEndosso>" +
         "  <mcs:InCancEndosso>N</mcs:InCancEndosso>" +
         "  <mcs:ApolAntCdProduto>0</mcs:ApolAntCdProduto>" +
         "  <mcs:ApolAntDtInicVig>0</mcs:ApolAntDtInicVig>" +
         "  <mcs:ApolAntDtFimVig>0</mcs:ApolAntDtFimVig>" +
         "  <mcs:ApolAntCepPernoite>0</mcs:ApolAntCepPernoite>" +
         "  <mcs:ApolAntCdCober>0</mcs:ApolAntCdCober>" +
         "  <mcs:ApolAntCdFranq>0</mcs:ApolAntCdFranq>" +
         "  <mcs:ApolAntCdCiaReno>0</mcs:ApolAntCdCiaReno>" +
         "  <mcs:ApolAntClasBonReno>0</mcs:ApolAntClasBonReno>" +
         "  <mcs:ApolAntQtdSinis>0</mcs:ApolAntQtdSinis>" +
         "  <mcs:ApolAntOrigSeguro>0</mcs:ApolAntOrigSeguro>" +
         "  <mcs:ApolAntTpPesProp>0</mcs:ApolAntTpPesProp>" +
         "  <mcs:ApolAntDtNascProp>0</mcs:ApolAntDtNascProp>" +
         "  <mcs:ApolAntSexoProp>0</mcs:ApolAntSexoProp>" +
         "  <mcs:ApolAntInFiAdoProp>0</mcs:ApolAntInFiAdoProp>" +
         "  <mcs:ApolAntEstCivProp>0</mcs:ApolAntEstCivProp>" +
         "  <mcs:ApolAntDtHabilProp>0</mcs:ApolAntDtHabilProp>" +
         "  <mcs:ApolAntCPFProp>0</mcs:ApolAntCPFProp>" +
         "  <mcs:ApolAntIndGarProp>0</mcs:ApolAntIndGarProp>" +
         "  <mcs:ApolAntTpPessCond>0</mcs:ApolAntTpPessCond>" +
         "  <mcs:ApolAntDtNascCond>0</mcs:ApolAntDtNascCond>" +
         "  <mcs:ApolAntSexoCond>0</mcs:ApolAntSexoCond>" +
         "  <mcs:ApolAntInFiAdoCond>0</mcs:ApolAntInFiAdoCond>" +
         "  <mcs:ApolAntEstCivCond>0</mcs:ApolAntEstCivCond>" +
         "  <mcs:ApolAntDtHabiCond>0</mcs:ApolAntDtHabiCond>" +
         "  <mcs:ApolAntCPFCond>0</mcs:ApolAntCPFCond>" +
         "  <mcs:ApolAntIndGarCond>0</mcs:ApolAntIndGarCond>" +
         "  <mcs:ApolAntCdVeic>0</mcs:ApolAntCdVeic>" +
         "  <mcs:ApolAntCdCombust>0</mcs:ApolAntCdCombust>" +
         "  <mcs:ApolAntAnoModVeic>0</mcs:ApolAntAnoModVeic>" +
         "  <mcs:ApolAntAnoFabrVeic>0</mcs:ApolAntAnoFabrVeic>" +
         "  <mcs:ApolAntFatAjustVMR>0</mcs:ApolAntFatAjustVMR>" +
         "  <mcs:ApolAntCdAntifurto>0</mcs:ApolAntCdAntifurto>" +
         "  <mcs:ApolAntcdUsoVeic>0</mcs:ApolAntcdUsoVeic>" +
         "  <mcs:ApolAntcdCarroc>0</mcs:ApolAntcdCarroc>" +
         "  <mcs:ApolAntQtdPassag>0</mcs:ApolAntQtdPassag>" +
         "  <mcs:ApolAntInZeroKm>0</mcs:ApolAntInZeroKm>" +
         "  <mcs:ApolAntTpKitGas>0</mcs:ApolAntTpKitGas>" +
         "  <mcs:ApolAntQtdPortVeic>0</mcs:ApolAntQtdPortVeic>" +
         "  <mcs:ApolAntInVlDeterm>0</mcs:ApolAntInVlDeterm>" +
         "  <mcs:ApolAntVlVeiculo>0</mcs:ApolAntVlVeiculo>" +
         "  <mcs:ApolAntPercDescCom>0</mcs:ApolAntPercDescCom>" +
         "  <mcs:ApolAntPercComCob>0</mcs:ApolAntPercComCob>" +
         "  <mcs:ApolAntPercComServ>0</mcs:ApolAntPercComServ>" +
         "  <mcs:ApolAntISAcess>0</mcs:ApolAntISAcess>" +
         "  <mcs:ApolAntISBlind>0</mcs:ApolAntISBlind>" +
         "  <mcs:ApolAntISKitGas>0</mcs:ApolAntISKitGas>" +
         "  <mcs:ApolAntISEquip>0</mcs:ApolAntISEquip>" +
         "  <mcs:ApolAntISMorte>0</mcs:ApolAntISMorte>" +
         "  <mcs:ApolAntISInvalidez>0</mcs:ApolAntISInvalidez>" +
         "  <mcs:ApolAntISRCFDM>0</mcs:ApolAntISRCFDM>" +
         "  <mcs:ApolAntISRCFDC>0</mcs:ApolAntISRCFDC>" +
         "  <mcs:ApolAntISRCFDMO>0</mcs:ApolAntISRCFDMO>" +
         "  <mcs:ApolAntISDespExtra>0</mcs:ApolAntISDespExtra>" +
         "  <mcs:ApolAntISEmerg>0</mcs:ApolAntISEmerg>" +
         "  <mcs:ApolAntISVidros>0</mcs:ApolAntISVidros>" +
         "  <mcs:ApolAntISCarReser>0</mcs:ApolAntISCarReser>" +
            " <mcs:ApolAntTamFrota>0</mcs:ApolAntTamFrota>" +
            " <mcs:ApolAntCdSemiReb>0</mcs:ApolAntCdSemiReb>" +
            " <mcs:ApolAntCdVidros>0</mcs:ApolAntCdVidros>" +
            " <mcs:ApolAntCdEmerg>0</mcs:ApolAntCdEmerg>" +
            " <mcs:ApolAntCdCarroRes>0</mcs:ApolAntCdCarroRes>" +
            " <mcs:ApolAntCdEquip>0</mcs:ApolAntCdEquip>" +
            " <mcs:ApolAntCdCorrSUSEP>0</mcs:ApolAntCdCorrSUSEP>" +
            " <mcs:ApolAntCdCorrGBS>0</mcs:ApolAntCdCorrGBS>" +
            " <mcs:ApolAntInCustoApol>0</mcs:ApolAntInCustoApol>" +
            " <mcs:ApolAntInCCB>0</mcs:ApolAntInCCB>" +
            " <mcs:ApolAntVlCCB>0</mcs:ApolAntVlCCB>" +
            " <mcs:ApolAntVlCusto>0</mcs:ApolAntVlCusto>" +
            " <mcs:ApolAntPrLiqCasc>0</mcs:ApolAntPrLiqCasc>" +
            " <mcs:ApolAntPrLiqDM>0</mcs:ApolAntPrLiqDM>" +
            " <mcs:ApolAntPrLiqDC>0</mcs:ApolAntPrLiqDC>" +
            " <mcs:ApolAntPrLiqDMO>0</mcs:ApolAntPrLiqDMO>" +
            " <mcs:ApolAntPrLiqMorte>0</mcs:ApolAntPrLiqMorte>" +
            " <mcs:ApolAntPrLiqInval>0</mcs:ApolAntPrLiqInval>" +
            " <mcs:ApolAntPrLiqDespEx>0</mcs:ApolAntPrLiqDespEx>" +
            " <mcs:ApolAntPrLiqAces>0</mcs:ApolAntPrLiqAces>" +
            " <mcs:ApolAntPrLiqBlIn>0</mcs:ApolAntPrLiqBlIn>" +
            " <mcs:ApolAntPrLiqKitGas>0</mcs:ApolAntPrLiqKitGas>" +
            " <mcs:ApolAntPrLiqEquip>0</mcs:ApolAntPrLiqEquip>" +
            " <mcs:ApolAntPrLiqEme24h>0</mcs:ApolAntPrLiqEme24h>" +
            " <mcs:ApolAntPrLiqCarRes>0</mcs:ApolAntPrLiqCarRes>" +
            " <mcs:ApolAntPrLiqVidros>0</mcs:ApolAntPrLiqVidros>" +
            " <mcs:ApolAntPrPgAuto>0</mcs:ApolAntPrPgAuto>" +
            " <mcs:ApolAntPrPgRCF>0</mcs:ApolAntPrPgRCF>" +
            " <mcs:ApolAntPrPgAPP>0</mcs:ApolAntPrPgAPP>" +
            " <mcs:ApolAntPrPgCusto>0</mcs:ApolAntPrPgCusto>" +
            " <mcs:ApolAntPrPgIOF>0</mcs:ApolAntPrPgIOF>" +
            " </mcs:Entrada>" +
            " </mcs:CalcSeg>" +
            " </soapenv:Body>" +
            " </soapenv:Envelope>";
		
		wr.write(xml); 
        wr.flush(); 
        
       System.out.println("OutPutStream >>  "+conn.getOutputStream());
        
        
        // Get the response  
        BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        
        System.out.println("OutPutStream >>  "+conn.getInputStream());
        
        while (rd.ready()){
        	line += rd.readLine();
        }
        wr.close();  
        rd.close(); 
        conn.getInputStream().close();
        System.out.println(line);  
	} catch (IOException e) {
		
		e.printStackTrace();
		
    } finally {
    	System.out.println("Fim");
    }
		
	}
	
}
